package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.Rent;
import service.RentService;

import java.util.List;

@Controller
@RequestMapping(value = "/rent")
public class RentController {
    @Autowired
    private RentService rentService;
    @RequestMapping(value = "/list")
    public String list(Model model){
        List<Rent> list = rentService.list();
        model.addAttribute("list",list);
        return "index";
    }
    @RequestMapping(value = "/update")
    public String update(int id,int status){
        if (status == 0){
            int result = rentService.update(id);
            return "index";
        }else {
            System.out.println("修改失败");
        }
        return null;
    }
    @RequestMapping(value = "/findList")
    public String findList(Model model,String carNum){
        List<Rent> list = rentService.rentlist(carNum);
        model.addAttribute("list",list);
        model.addAttribute("carNum",carNum);
        return "index";
    }
}
